package com.katsu.myapplib.http.base64;

import android.graphics.Bitmap;

import com.katsu.myapplib.util.UtilBitmap;

public class AsyBitmapBase64 implements AsyBase64 {

    private Bitmap b;

    private int s;

    public AsyBitmapBase64(Bitmap bitmap, int size) {

        this.b = bitmap;

        this.s = size;

    }

    @Override
    public String toBase64() {

        try {

            if (s > 0) {

                return UtilBitmap.toBase64(UtilBitmap.compressQuality(b, s));

            } else {

                return UtilBitmap.toBase64(b);

            }

        } catch (Exception e) {

            e.printStackTrace();

        }

        return "";

    }
}
